package fcrpt

/**
 * MES库产品统计表
 * @Author Ivan
 * @Date 2019/4/19
 */
class PartTotalController {

    def dynamicQueryService

    /**
     * MES库产品统计表 
     * @Author Ivan
     * @Params
     * @Return 
     */
    def partTotal() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        def report_011 = []
        def tableHeadList = []
        def totalCount = 0
        if ('Excel'.equals(params.EXPORT_CONTENT_NAME)) {
            params.SYS_QUERY_NAME = 'partTotalList'
            report_011 = dynamicQueryService.queryForList(params)
            if (report_011.size() > 0) {
                tableHeadList = report_011[0].keySet()
            }
            params.SYS_QUERY_NAME = 'partTotalCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        }
        [
                pageCurrent   : pageCurrent,
                pageSize      : pageSize,
                pageSizeList  : pageSizeList,
                startno       : params.startno ?: '',
                endno         : params.endno ?: '',
                startTime     : params.startTime ?: '',
                endTime       : params.endTime ?: '',
                shipType      : params.shipType ?: '',
                partTuId      : params.partTuId ?: '',
                materielCode  : params.materielCode ?: '',
                stockCode     : params.stockCode ?: '',
                report_011    : report_011,
                tableHeadList : tableHeadList,
                totalCount    : totalCount,
                SYS_QUERY_NAME: 'partTotalList'
        ]
    }

    /**
     * 出入库明细
     * @Author Ivan
     * @Params
     * @Return 
     */
    def outInLotDetail() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        params.SYS_QUERY_NAME = 'outInLotDetailList'
        def report_011 = dynamicQueryService.queryForList(params)
        def tableHeadList = []
        if (report_011.size() > 0) {
            tableHeadList = report_011[0].keySet()
        }
        params.SYS_QUERY_NAME = 'outInLotDetailCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        [
                pageCurrent   : pageCurrent,
                pageSize      : pageSize,
                pageSizeList  : pageSizeList,
                startno       : params.startno ?: '',
                endno         : params.endno ?: '',
                startTime     : params.startTime ?: '',
                endTime       : params.endTime ?: '',
                shipType      : params.shipType ?: '',
                partTuId      : params.partTuId ?: '',
                materielCode  : params.materielCode ?: '',
                stockCode     : params.stockCode ?: '',
                report_011    : report_011,
                tableHeadList : tableHeadList,
                totalCount    : totalCount,
                SYS_QUERY_NAME: 'outInLotDetailList'
        ]
    }

    /**
     * 出入库批次明细
     * @Author Ivan
     * @Params
     * @Return
     */
    def outInLotStockDetail() {
        request.setCharacterEncoding("UTF-8")
        response.setContentType("text/html;charset=UTF-8")
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10, 20, 50, 100]
        params.SYS_QUERY_NAME = 'outInTypeList'
        def outInTypeList = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'outInLotStockDetailList'
        def report_011 = dynamicQueryService.queryForList(params)
        def tableHeadList = []
        if (report_011.size() > 0) {
            tableHeadList = report_011[0].keySet()
        }
        params.SYS_QUERY_NAME = 'outInLotStockDetailCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        [
                pageCurrent   : pageCurrent,
                pageSize      : pageSize,
                pageSizeList  : pageSizeList,
                startno       : params.startno ?: '',
                endno         : params.endno ?: '',
                startTime     : params.startTime ?: '',
                endTime       : params.endTime ?: '',
                outInType     : params.outInType ?: '',
                partTuId      : params.partTuId ?: '',
                materielCode  : params.materielCode ?: '',
                stockCode     : params.stockCode ?: '',
                lotId         : params.lotId ?: '',
                state         : params.state ?: '',
                clazz         : params.clazz ?: '',
                outQty        : params.outQty ?: '',
                outInTypeList : outInTypeList,
                report_011    : report_011,
                tableHeadList : tableHeadList,
                totalCount    : totalCount,
                SYS_QUERY_NAME: 'outInLotStockDetailList'
        ]
    }
}